home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / live / usr / share / vim / vim60 / plugin / rrhelper.vim < prev    next >
Encoding:
Text File  |  2002-06-19  |  1.0 KB  |  38 lines

  1. " Vim plugin with helper function(s) for --remote-wait
  2. " Maintainer: Flemming Madsen <fma@cci.dk>
  3. " Last Change: 2001 Sep 05
  4.  
  5. " Setup answers for a --remote-wait client who will assume
  6. " a SetupRemoteReplies() function in the command server
  7.  
  8. if has("clientserver")
  9.   function SetupRemoteReplies()
  10.     let cnt = 0
  11.     let max = argc()
  12.  
  13.     let id = expand("<client>")
  14.     if id == 0
  15.       return
  16.     endif
  17.     while cnt < max
  18.       " Handle same file from more clients and file being more than once
  19.       " on the command line by encoding this stuff in the group name
  20.       let uniqueGroup = "RemoteReply_".id."_".cnt
  21.       execute "augroup ".uniqueGroup
  22.       execute 'autocmd '.uniqueGroup.' BufUnload '.argv(cnt).'  call DoRemoteReply("'.id.'", "'.cnt.'", "'.uniqueGroup.'", "'.argv(cnt).'")'
  23.       let cnt = cnt + 1
  24.     endwhile
  25.     augroup END
  26.   endfunc
  27.  
  28.   function DoRemoteReply(id, cnt, group, file)
  29.     call server2client(a:id, a:cnt)
  30.     execute 'autocmd! '.a:group.' BufUnload '.a:file
  31.     execute 'augroup! '.a:group
  32.   endfunc
  33.  
  34. endif
  35.  
  36.  
  37. " vim: set sw=2 sts=2 :
  38.